#include <unistd.h>
#include "sys.h"
#include "video.h"

static void  exit_callback(lv_event_t *event);

static Video *video;
static mutex ui_mutex;

int main(void)
{
    sys_init();
    lv_init(); // lvgl gui初始化
    lv_port_disp_init();
    lv_port_indev_init();
    lv_port_fs_init();

    video = new Video(exit_callback, ui_mutex);

    while (1)
    {
        ui_mutex.lock();
        uint32_t ms = lv_task_handler();
        ui_mutex.unlock();
        
        usleep(ms * 1000);
    }
}

/*
 *@brief 退出回调函数
 */
static void  exit_callback(lv_event_t *event)
{
    delete video;

    exit(0);
}
